package crack;

import fem2.AbstractStructuralCrackDemo;
import fem2.Constraint;
import fem2.MaterialModel;
import fem2.Mesh;
import fem2.MeshUtilities;
import fem2.Model;
import fem2.enu.State;
import fem2.material.StVenantKirchhoffMM;
import fem2.material.cohesive_law.CohesiveLaw;
import fem2.material.cohesive_law.Mode1AbsCohesiveLaw;

public abstract class AbstractThreePointTestUsingSDAElementDemo extends AbstractStructuralCrackDemo {

	public AbstractThreePointTestUsingSDAElementDemo() {
		projectDir = "/home/hbui/kratos_janosch";
		projectName = "three-point-test2.gid";
	}

	@Override
	public Model createConditions(Model m) {
		Mesh mesh = m.getMesh();
		/*
		 * conditions
		 */
		Constraint c1 = new Constraint(false, false);
		Constraint c2 = new Constraint(true, false);
		Constraint c3 = new Constraint(true, false);
		double du = -1;
		c3.setValue(1, du);
		MeshUtilities.seekNode(mesh, 0, 0).setConstraint(c1);
		MeshUtilities.seekNode(mesh, 2000, 0).setConstraint(c2);
		MeshUtilities.seekNode(mesh, 1000, 500).setConstraint(c3);

		return m;
	}

	@Override
	public MaterialModel createMaterial(Model m) {
		double E = 20e3;
		double nu = 0.15;
		double t = 100;
		State ss = State.PLANE_STRESS;
		MaterialModel mm = new StVenantKirchhoffMM(E, nu, t, 0, ss);
		return mm;
	}

	@Override
	public CohesiveLaw createCohesiveLaw(Model m) {
		double ft = 2.5;
		double Gf = 0.1;
		double km = 1e-1;
		return new Mode1AbsCohesiveLaw(Gf, ft, km);
	}

}
